home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form frmBitMap
- BackColor = &H00C0C0C0&
- Caption = "Master BitMap"
- ClientHeight = 4965
- ClientLeft = 2730
- ClientTop = 2085
- ClientWidth = 3525
- ClipControls = 0 'False
- ControlBox = 0 'False
- Height = 5655
- Left = 2670
- LinkTopic = "Form1"
- MinButton = 0 'False
- ScaleHeight = 331
- ScaleMode = 3 'Pixel
- ScaleWidth = 235
- Top = 1455
- Width = 3645
- Begin VScrollBar vsrPosition
- Enabled = 0 'False
- Height = 1860
- Left = 0
- TabIndex = 6
- Top = 0
- Value = 1
- Width = 390
- End
- Begin PictureBox picCol16
- AutoRedraw = -1 'True
- AutoSize = -1 'True
- Height = 45
- Left = 4575
- Picture = FRMBITMA.FRX:0000
- ScaleHeight = 15
- ScaleWidth = 15
- TabIndex = 5
- Top = 675
- Visible = 0 'False
- Width = 45
- End
- Begin PictureBox picSwap
- Height = 735
- Left = 3675
- ScaleHeight = 47
- ScaleMode = 3 'Pixel
- ScaleWidth = 99
- TabIndex = 4
- Top = 1440
- Visible = 0 'False
- Width = 1515
- End
- Begin HScrollBar HScroll1
- Height = 240
- Left = 375
- TabIndex = 3
- Top = 1665
- Width = 2040
- End
- Begin VScrollBar VScroll1
- Height = 1680
- Left = 2250
- TabIndex = 2
- Top = 0
- Width = 390
- End
- Begin PictureBox picFrame
- BorderStyle = 0 'None
- Height = 1635
- Left = 450
- ScaleHeight = 109
- ScaleMode = 3 'Pixel
- ScaleWidth = 136
- TabIndex = 0
- Top = 0
- Width = 2040
- Begin PictureBox picBitMap
- AutoRedraw = -1 'True
- BackColor = &H00C0C0C0&
- Height = 2580
- Left = 0
- ScaleHeight = 170
- ScaleMode = 3 'Pixel
- ScaleWidth = 364
- TabIndex = 1
- Top = 0
- Width = 5490
- End
- End
- Begin Menu mnuExit
- Caption = "E&xit"
- End
- Begin Menu mnuEdit
- Caption = "&Edit"
- End
- Begin Menu mnuDelete
- Caption = "&Delete"
- End
- Option Explicit
- Dim LastPosition As Integer
- Dim TotalButtonHeight As Integer
- Dim Clicked As Integer
- Dim Changing As Integer
- Sub Form_Activate ()
- TotalButtonHeight = Bitmap.ButtonHeight + (Bitmap.Border * 2)
- VScroll1.LargeChange = TotalButtonHeight
- VScroll1.Value = VScroll1.Min
- HelpItem = 15
- End Sub
- Sub Form_KeyDown (KeyCode As Integer, Shift As Integer)
- If KeyCode = &H70 Then Cheap_Help Format$(HelpItem)
- End Sub
- Sub Form_KeyPress (KeyAscii As Integer)
- mnuExit_Click
- End Sub
- Sub Form_Load ()
- Position_Form frmBitMap
- 'To make the Master Bitmap picture contain a palette compatible
- 'with the buttons created by VB, I created picCol16 which is 1 pixel saved as a
- '16 color bitmap.
- picBitMap = picCol16
- picSwap = picCol16
- KeyPreview = True
- End Sub
- ' Adapted from code in the Visual Basic Help file
- ' Select Help
- ' then 'Obtaining Technical Support'
- ' then 'Knowledge Based Articles on Visual Basic'
- ' then 'How to create a scrollable viewport in Visual Basic'
- Sub Form_Resize ()
- vsrPosition.Move 0, 0, vsrPosition.Width, frmBitMap.ScaleHeight
- picframe.Move vsrPosition.Width, 0, frmBitMap.ScaleWidth - VScroll1.Width - vsrPosition.Width, frmBitMap.ScaleHeight - HSCroll1.Height
- picBitMap.Move 0, 0
- ' Position the horizontal scroll bar.
- HSCroll1.Top = picframe.Height
- HSCroll1.Left = vsrPosition.Width
- HSCroll1.Width = picframe.Width
- ' Position the vertical scroll bar.
- VScroll1.Top = 0
- VScroll1.Left = picframe.Width + vsrPosition.Width
- VScroll1.Height = picframe.Height
- 'Position the Arrows
- ' Set the Max value for the scroll bars.
- HSCroll1.Max = picBitMap.Width - picframe.Width
- VScroll1.Max = picBitMap.Height - picframe.Height
- ' Determine if child picture will fill up screen.
- ' If so, then there is no need to use scroll bars.
- VScroll1.Enabled = (picframe.Height < picBitMap.Height)
- HSCroll1.Enabled = (picframe.Width < picBitMap.Width)
- End Sub
- Sub HScroll1_Change ()
- ' picBitMap.Left is set to the negative of the value because
- ' as you scroll the scroll bar to the right, the display
- ' should move to the Left, showing more of the right
- ' of the display, and vice-versa when scrolling to the
- ' left.
- 'See form-resize event for more info
- picBitMap.Left = -HSCroll1.Value
- End Sub
- Sub mnuDelete_Click ()
- If picBitMap.ScaleHeight <= TotalButtonHeight + Bitmap.Border Then
- MsgBox "Sorry! I can't delete the last button"
- Exit Sub
- End If
- If Show_Message("DELETE") Then Exit Sub 'Check that a button has been click
- Reset_BitMap 'make button normal (not inverted)
- 'Resize the swap & master bitmap picture. Copy all but the last button from the master bitmap
- 'Then copy the swap picture back into the master bitmap
- picBitMap.Height = picBitMap.Height - TotalButtonHeight
- picSwap.Width = picBitMap.Width
- picSwap.Height = picBitMap.Height
- Bitmap.Position = Bitmap.Position - TotalButtonHeight
- BitBlt picSwap.hDC, 0, 0, picBitMap.ScaleWidth, picBitMap.ScaleHeight, picBitMap.hDC, 0, 0, SRCCOPY
- picBitMap.Picture = picSwap.Image
- picSwap = picCol16
- picSwap.AutoRedraw = False
- Bitmap.Changed = True
- picBitMap.Refresh
- End Sub
- Sub mnuEdit_Click ()
- If Clicked Then
- If Show_Message("EDIT") Then Exit Sub 'is a button selected?
- 'Copy the button into the 'Up' button picture
- BitBlt B(0).hDC, 0, 0, Bitmap.ButtonWidth, Bitmap.ButtonHeight, picBitMap.hDC, Bitmap.Border, vsrPosition + Bitmap.Border, NOTSRCCOPY
- B(0).Refresh
- frmButton!picDraw.Refresh
- Bitmap.Position = picBitMap.ScaleHeight - (Bitmap.ButtonHeight + (Bitmap.Border * 2))
- Editing = True
- UpDated = False
- mnuExit_Click
- End If
- End Sub
- Sub mnuExit_Click ()
- Reset_BitMap
- frmBitMap.Hide
- End Sub
- Sub picBitMap_MouseUp (button As Integer, Shift As Integer, X As Single, Y As Single)
- Changing = True 'Flag to stop vscrPosition altering the buttons
- If Not Clicked Then
- vsrPosition.Max = (picBitMap.ScaleHeight - TotalButtonHeight)
- vsrPosition.SmallChange = TotalButtonHeight
- vsrPosition.LargeChange = TotalButtonHeight
- vsrPosition.Enabled = True
- 'initialize the swap picture
- picSwap.AutoRedraw = True
- picSwap.Width = picBitMap.Width
- picSwap.Height = TotalButtonHeight + (getSystemMetrics(SM_CYBORDER) * 2)
- End If
- 'Get the position of the top of the button
- vsrPosition = (Y \ TotalButtonHeight) * TotalButtonHeight
- If Clicked Then
- 'A button is already inverted so restore it to normal
- BitBlt picBitMap.hDC, 0, LastPosition, picBitMap.ScaleWidth, TotalButtonHeight, 0&, 0, LastPosition, DSTINVERT
- End If
- LastPosition = vsrPosition 'Remember where the inverted button is
- 'Invert the selected button
- BitBlt picBitMap.hDC, 0, vsrPosition, picBitMap.ScaleWidth, TotalButtonHeight, 0&, 0, vsrPosition, DSTINVERT
- picBitMap.Refresh
- Clicked = True
- Changing = False
- End Sub
- Sub picBitMap_Resize ()
- Form_Resize
- End Sub
- Sub Reset_BitMap ()
- If Clicked Then
- vsrPosition.Enabled = False
- 'One of the buttons is inverted so restore it to normal
- BitBlt picBitMap.hDC, 0, LastPosition, picBitMap.ScaleWidth, TotalButtonHeight, 0&, 0, LastPosition, DSTINVERT
- End If
- Clicked = False
- End Sub
- Function Show_Message (Msg As String) As Integer
- If vsrPosition <> picBitMap.ScaleHeight - (TotalButtonHeight + Bitmap.Border) Then
- MsgBox "This programme can only " & Msg & " the last button" & CR & "in the Bitmap. Move the button to the bottom" & CR & "Then try again", 48
- Show_Message = True
- End If
- End Function
- Sub VScroll1_Change ()
- ' picBitMap.Top is set to the negative of the value because
- ' as you scroll the scroll bar down, the display
- ' should move up, showing more of the bottom
- ' of the display, and vice-versa when scrolling up.
- 'See form-resize event for more info
- picBitMap.Top = -VScroll1.Value
- End Sub
- Sub vsrPosition_Change ()
- If Changing Then Exit Sub
- 'Only allow steps of one button
- If Abs(vsrPosition - LastPosition) <> TotalButtonHeight Then
- vsrPosition = LastPosition
- Exit Sub
- End If
- Bitmap.Changed = True
- 'Puts the button above into the swap picture
- 'then puts the current button into the position above
- 'then puts the swap picture into the current position
- 'then makes the position above, the current position
- BitBlt picSwap.hDC, 0, 0, picSwap.ScaleWidth, TotalButtonHeight, picBitMap.hDC, 0, LastPosition, SRCCOPY
- BitBlt picBitMap.hDC, 0, LastPosition, picSwap.ScaleWidth, TotalButtonHeight, picBitMap.hDC, 0, vsrPosition, SRCCOPY
- BitBlt picBitMap.hDC, 0, vsrPosition, picSwap.ScaleWidth, TotalButtonHeight, picSwap.hDC, 0, 0, SRCCOPY
- LastPosition = vsrPosition
- picBitMap.Refresh
- End Sub
-